<template>
  <div>
    <el-form inline :model="queryData" ref="queryData" class="query-form">
      <el-form-item label="UID:" prop="id">
        <el-input type="number"  v-model="queryData.id" placeholder="请输入" style="width: 200px" clearable
                  @clear="formClear('id')"/>
      </el-form-item>
      <el-form-item label="手机:" prop="phone">
        <el-input type="number" v-model="queryData.phone" placeholder="请输入" style="width: 200px" clearable
                  @clear="formClear('phone')"/>
      </el-form-item>
      <el-form-item label="真实姓名:" prop="name">
        <el-input v-model="queryData.name" placeholder="请输入" style="width: 200px" clearable
                  @clear="formClear('name')"/>
      </el-form-item>
      <el-form-item label="注册时间:" prop="createTime">
        <el-date-picker v-model="queryData.createTime" type="date" placeholder="选择日期" value-format="yyyy-MM-dd"
                        @clear="formClear('createTime')">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="审核状态:" prop="authentication">
        <el-select v-model="queryData.authentication" placeholder="请选择" clearable @clear="formClear('authentication')"
                   style="width: 200px">
          <el-option label="待审核" value="0"></el-option>
          <el-option label="已审核" value="1"></el-option>
          <el-option label="驳回" value="2"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">查 询</el-button>
        <el-button @click="onReset">重 置</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="tableList" border style="width: 100%;">
      <el-table-column prop="id" label="UID" align="center"/>
      <el-table-column label="头像" align="center">
        <template slot-scope="{row}">
          <el-image style="width: 30px; height: 30px; border-radius: 50%" :src="row.avatar" fit="cover"></el-image>
        </template>
      </el-table-column>
      <el-table-column prop="nickName" label="用户昵称" align="center" show-overflow-tooltip/>
      <el-table-column prop="phone" label="用户手机" align="center"/>
      <el-table-column prop="name" label="姓名" align="center"/>
      <el-table-column prop="typeString" label="身份类型" align="center"/>
      <el-table-column prop="createTime" label="提交时间" align="center"/>
      <el-table-column prop="authenticationString" label="状态" align="center" />
      <el-table-column label="操作" align="center" width="100">
        <template slot-scope="{row}">
          <el-button type="text" @click="lookOverEvent(row)">查 看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <Paging v-model="queryData" @change="getRequest"></Paging>
    <el-drawer title="申请信息" :visible.sync="drawer" direction="rtl" :before-close="drawerClose" size="500px"
               destroy-on-close class="drawer-css">
      <AuditForm :entity="entity" status="1" v-if="drawer" @close="drawerClose" @refresh="getRequest"></AuditForm>
    </el-drawer>
  </div>
</template>

<script>
  import { mapGetters } from 'vuex'

  export default {
    computed: {
      ...mapGetters(['confirm'])
    },
    components: {
      AuditForm: () => import('./AuditForm.vue')
    },
    name: 'landlordAuditList',
    data() {
      return {
        tableList: [],
        queryData: {
          authentication: null, // 状态：0审核中；1已审核；-1已屏蔽
          createTime: null, // 创建时间
          id: null, //用户id
          name: null, // 房东姓名
          phone: null, // 房东手机号
          pageNum: 1,
          pageSize: 10,
          total: 0
        },
        drawer: false,
        entity: null
      }
    },
    beforeMount() {
      this.getRequest()
    },
    methods: {
      /**
       * 重置事件
       */
      onReset() {
        this.queryData.pageNum = 1
        this.$refs['queryData'].resetFields()
        this.getRequest()
      },
      /**
       * 查询条件提交事件
       */
      onSubmit() {
        this.queryData.pageNum = 1
        this.getRequest()
      },
      /**
       * 列表请求事件
       */
      async getRequest() {
        const params = JSON.parse(JSON.stringify(this.queryData))
        const res = await this.$ajax.get('/my/house/master/backstage/list', { params })
        this.queryData.total = res.total
        this.tableList = res.rows
      },
      /**
       * form-input 置空事件
       */
      formClear(key) {
        this.queryData[key] = null
        this.onSubmit()
      },
      /**
       * 查看按钮事件
       */
      lookOverEvent (row) {
        this.entity = JSON.parse(JSON.stringify(row))
        this.drawer = true
      },
      drawerClose () {
        this.drawer = false
      }
    }
  }
</script>

<style scoped>
::v-deep input::-webkit-outer-spin-button,
::v-deep input::-webkit-inner-spin-button {
  -webkit-appearance: none !important;
}
/deep/ input[type='number'] {
  -moz-appearance: textfield !important;
  }
</style>
